//package com.example.demo.controller;
//
//import com.example.demo.quartz.QuartzUtil;
//import com.example.demo.quartz.job.IQuartzJob;
//import com.example.demo.quartz.job.QuartzJobPushMember;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.apache.logging.log4j.LogManager;
//import org.apache.logging.log4j.Logger;
//import org.quartz.Scheduler;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
///**
// * Created by Wen Gao on 2018/7/18.
// */
//
//@RestController
//@RequestMapping("/quartz")
//public class QuartzController {
//
//    Logger logger = LogManager.getLogger(this.getClass());
//
//    @Autowired
//    Scheduler scheduler;
//
//    @Autowired
//    QuartzUtil quartzUtil;
//
//    @ApiOperation(value = "立即运行一个job", notes = "notes")
//    @GetMapping("/runNow")
//    public ResponseEntity runNow(@ApiParam(name = "jobId", value = "jobId", required = true) @RequestParam(name = "jobId") String jobId,
//                                 @ApiParam(name = "jobName", value = "jobName", required = true) String jobName,
//                                 @ApiParam(name = "jobGroup", value = "jobGroup", required = true) String jobGroup) {
//        logger.info("通过controller触发quartzJob : jobId:" + jobId + " , jobName:" + jobName + " , jobGroup:" + jobGroup);
//        try {
//            IQuartzJob quartzJob = new QuartzJobPushMember(jobId, jobName, jobGroup);
//            quartzUtil.runJobNow(quartzJob);
//        } catch (Exception e) {
//            logger.error(e);
//            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e);
//        }
//        return ResponseEntity.ok().body("OK");
//    }
//
//    @ApiOperation(value = "暂停运行一个job", notes = "notes")
//    @GetMapping("/pause")
//    public ResponseEntity pause(@ApiParam(name = "jobId", value = "jobId", required = true) @RequestParam(name = "jobId") String jobId,
//                                 @ApiParam(name = "jobName", value = "jobName", required = true) String jobName,
//                                 @ApiParam(name = "jobGroup", value = "jobGroup", required = true) String jobGroup) {
//        logger.info("通过controller触发quartzJob : jobId:" + jobId + " , jobName:" + jobName + " , jobGroup:" + jobGroup);
//        try {
//            IQuartzJob quartzJob = new QuartzJobPushMember(jobId, jobName, jobGroup);
//            quartzUtil.pauseJob(quartzJob);
//        } catch (Exception e) {
//            logger.error(e);
//            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e);
//        }
//        return ResponseEntity.ok().body("OK");
//    }
//
//    @ApiOperation(value = "继续运行一个暂停的job", notes = "notes")
//    @GetMapping("/resume")
//    public ResponseEntity resume(@ApiParam(name = "jobId", value = "jobId", required = true) @RequestParam(name = "jobId") String jobId,
//                                @ApiParam(name = "jobName", value = "jobName", required = true) String jobName,
//                                @ApiParam(name = "jobGroup", value = "jobGroup", required = true) String jobGroup) {
//        logger.info("通过controller触发quartzJob : jobId:" + jobId + " , jobName:" + jobName + " , jobGroup:" + jobGroup);
//        try {
//            IQuartzJob quartzJob = new QuartzJobPushMember(jobId, jobName, jobGroup);
//            quartzUtil.resumeJob(quartzJob);
//        } catch (Exception e) {
//            logger.error(e);
//            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e);
//        }
//        return ResponseEntity.ok().body("OK");
//    }
//}
